home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
amiga.free
/
sorgenti vari
/
wolfedit2 2.0.4 source.sit
/
WolfEdit2 2.0.4 Source
/
UImagePalette.p
< prev
next >
Wrap
Text File
|
1995-10-15
|
2KB
|
99 lines
unit UImagePalette;
interface
implementation
uses
UList, UEditArt;
procedure TImagePalette.IImagePalette (itsCols, itsNumItems: integer);
var
itsRows: integer;
begin
itsRows := (itsNumItems + (itsCols - 1)) div itsCols;
IList(20, 20, itsCols, itsRows, 1, []);
fNumItems := itsNumItems;
end;
procedure TImagePalette.DrawCell (cell: Point; r: Rect; var hilite: boolean);
var
n: integer;
oldPen: PenState;
begin
n := ItemNumber(cell);
if n >= 0 then begin
if ItemSelectable(n) then begin
InsetRect(r, 2, 2);
DrawImage(n, r);
end
else begin
GetPenState(oldPen);
PenNormal;
MoveTo(r.left, r.top);
LineTo(r.right, r.bottom);
MoveTo(r.right, r.top);
LineTo(r.left, r.bottom);
SetPenState(oldPen);
end;
end
else
EraseRect(r);
end;
procedure TImagePalette.ChangeCellHilite (cell: Point; hilite: boolean);
var
r: Rect;
begin
Focus;
CellToRect(cell, r);
PenNormal;
PenSize(2, 2);
PenMode(patXor);
FrameRect(r);
end;
procedure TImagePalette.SetSelectionRect (newSel: Rect);
var
item: integer;
begin
item := ItemNumber(newSel.topLeft);
if (item >= 0) & ItemSelectable(item) then begin
inherited SetSelectionRect(newSel);
ItemSelected(item);
end;
end;
procedure TImagePalette.DrawImage (itemNo: integer; r: Rect);
begin
{Override this}
end;
function TImagePalette.ItemNumber (cell: Point): integer;
var
n: integer;
begin
n := cell.v * fDimensions.right + cell.h;
if (n < 0) | (n >= fNumItems) then
n := -1;
ItemNumber := n;
end;
procedure TImagePalette.ItemSelected (itemNum: integer);
begin
fDialog.SelectArt(itemNum);
end;
procedure TImagePalette.InvalidateItem (itemNo: integer);
var
cell: Point;
begin
SetPt(cell, itemNo mod fDimensions.right, itemNo div fDimensions.right);
InvalidateCell(cell);
end;
function TImagePalette.ItemSelectable (item: integer): boolean;
begin
ItemSelectable := true;
end;
end.